package com.sample.FinalProject;

import java.util.ArrayList;

import android.graphics.Color;

public class Turret extends Building {
int damage, radius;
boolean isShooting=false;
public Turret(int newX, int newY, int colour){
	if(colour==Color.GRAY){
		isEnemy=true;	
		}
		else{
		isEnemy=false;	
		}	
x=newX;
y=newY;
color=colour;
damage=20;	
radius=20;	
max_health=750;
health=max_health;
}
public int getRadius(){
return radius;	
}
public int[] target(FinalView fv){
ArrayList <Square> squares=fv.getSquares();
ArrayList <Circle> CircleUnits=fv.getCircleUnits();	
MainShape main=fv.getMain();	
int[] tempInt=new int[2];
tempInt[0]=0;
tempInt[1]=0;
if(isEnemy==true && Math.abs(main.getX()-x)<=150 && Math.abs(main.getY()-y)<=150){
	main.setHealth(main.getHealth()-damage);
	tempInt[0]=main.getX();
	tempInt[1]=main.getY();
	isShooting=true;
}
for (int z = 0; z<CircleUnits.size(); z++){
	if(isEnemy!= CircleUnits.get(z).isEnemy() && Math.abs(CircleUnits.get(z).getX()-x)<=150 && Math.abs(CircleUnits.get(z).getY()-y)<=150){
				CircleUnits.get(z).setHealth(CircleUnits.get(z).getHealth()-damage);
				tempInt[0]=CircleUnits.get(z).getX();
				tempInt[1]=CircleUnits.get(z).getY();
				isShooting=true;
		}	
}
for (int w = 0; w<squares.size(); w++){
	if(isEnemy!= squares.get(w).isEnemy() && Math.abs(squares.get(w).getX()-x)<=150 && Math.abs(squares.get(w).getY()-y)<=150){
				squares.get(w).setHealth(squares.get(w).getHealth()-damage);
				tempInt[0]=squares.get(w).getX();
				tempInt[1]=squares.get(w).getY();
				isShooting=true;
		}
		}

return tempInt;	
}
public boolean isShooting(){
return isShooting;	
}
public void notShooting(){
isShooting=false;	
}
}
